import json

from django.http import HttpResponse
from django.shortcuts import render, render_to_response
from Common import Fookie, Fession_mini

# Create your views here.

#在线工具
from GoodTools.GoodToolsControl.everyDay import _everyDay
from GoodTools.ToolsControl import index


def everyDay(request):
    all = _everyDay().get_all_mag(2)
    return  render_to_response('everyDay.html', {'all':all ,'Meg':index._index().main()})

def useFookie(request):

    option = request.GET.get("option")
    key = request.GET.get("key")
    value = request.GET.get("value")
    print(option,key,value)
    if option == 'get' and key is not None:
        return HttpResponse(json.dumps(Fookie.getFookieFile(key)))
    elif option == 'set' and key is not None and value is not None:
        print("这是set")
        return HttpResponse(json.dumps(Fookie.setFookieFile(key , value)))
    elif option == 'del' and key is not None:
        return HttpResponse(json.dumps(Fookie.delFookie(key)))
    print('aksdjfkl;sdf asdf asd fasdf dasd asd f; ')

def useFession(request):

    option = request.GET.get("option")
    key = request.GET.get("key")
    value = request.GET.get("value")
    print(option,key,value)
    if option == 'get' and key is not None:

        return HttpResponse(json.dumps(Fession_mini.getFessionMini(key)))
    elif option == 'set' and key is not None and value is not None:
        print("这是set")
        return HttpResponse(json.dumps(Fession_mini.setFessionMini(key , value)))
    elif option == 'del' and key is not None:
        return HttpResponse(json.dumps(Fession_mini.delFessionMini(key)))
    print('aksdjfkl;sdf asdf asd fasdf dasd asd f; ')